package com.lock.chess.utils;

import cn.hutool.json.JSONObject;
import com.lock.chess.Enums.MessageEnum;
import com.lock.chess.controller.WebSocketServer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class SocketResponse {
    private String type;
    private int code;
    private String message;
    private JSONObject data;

    public static String success(String type, JSONObject data)
    {
        return new JSONObject(new SocketResponse(type, 200, "成功", data)).toString();
    }

    public static String fail(String type, String message)
    {
        return new JSONObject(new SocketResponse(type, 500, message, null)).toString();
    }
}
